import openpyxl
import os
import sys
import shutil
from itertools import groupby
import json
import zipfile
from win32com.client import Dispatch, constants, gencache, DispatchEx

from variable import *
from CreateThreeFolder import *
from CopyUsersettingFolder import *
from Copy_EightATPReports import *
from Copy_0943 import *
from Copy_590 import *
from Copy_ATPReportBefore import *
from CreateServicePhoto import *
from CopyATPReportAfter import *
from Delete import *
from WriteServiceReport import *

createthreefolder()
# copyusersettingfolder()
copy_eightATPreports()
copy_0943()
copy_ATPreportsbefore()
createservicephoto()
copy_590()
copyATPreportafter()
deletefile()
WriteServiceReportBefore()
WriteServiceReportAfter()

# root 所指的是当前正在遍历的这个文件夹的本身的地址
# dirs 是一个 list，内容是该文件夹中所有的目录的名字(不包括子目录)
# files 同样是 list, 内容是该文件夹中所有的文件(不包括子目录)
# for root, dirs, files in os.walk(UserSettingsCopyFilePath):
#     for file in files:
#         src_file = os.path.join(root, file)
#         shutil.copy(src_file, MailWork_path)
#         print(src_file)
# print('拷贝配置文件开结束...开始压缩') "复制文件"

'''startdir = UserSettings_dstpath  #要压缩的文件夹路径
UserSettingsZipName = "UserSettings" + "_" + PIUSerialNumber \
                      + "_" + Time_ATP_1 +'.rar' # 压缩后文件夹的名字
z = zipfile.ZipFile(UserSettingsZipName,'w',zipfile.ZIP_DEFLATED) #参数一：文件夹名
for dirpath, dirnames, filenames in os.walk(startdir):
    fpath = dirpath.replace(startdir,'') #这一句很重要，不replace的话，就从根目录开始复制
    fpath = fpath and fpath + os.sep or ''#这句话理解我也点郁闷，实现当前文件夹以及包含的所有文件的压缩
    for filename in filenames:
        z.write(os.path.join(dirpath, filename),fpath+filename)
print ('--------------压缩成功---------------')
z.close()'''








